package org.example.design.flyweight.test1;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/**
 * @author huangshen
 * @version 0
 * @description 大型字符类
 * @since 2022/2/11 14:37
 */
public class BigChar {

    private char charName;

    private String fontData;

    public BigChar (char charName) {
        this.charName = charName;

        try (
            BufferedReader reader = new BufferedReader(
                    new FileReader("big" + charName + ".txt")
            )
        ){
            String line;
            StringBuilder buffer = new StringBuilder();
            while((line = reader.readLine()) != null) {
                buffer.append(line);
                buffer.append("\n");
            }
            this.fontData = buffer.toString();
        } catch (IOException e) {
            this.fontData = charName + "?";
        }
    }

    public void print() {
        System.out.println(fontData);
    }
}
